import java.util.ArrayList;
import java.util.List;

/**
 * @author LKQ
 * @date 2022/1/8 11:23
 * @description
 */
public class FormalSolution2 {
    public static void main(String[] args) {

    }
    public boolean findTarget(TreeNode root, int k) {
        List < Integer > list = new ArrayList();
        inorder(root, list);
        int l = 0, r = list.size() - 1;
        while (l < r) {
            int sum = list.get(l) + list.get(r);
            if (sum == k) {
                return true;
            }
            if (sum < k) {
                l++;
            } else {
                r--;
            }
        }
        return false;
    }
    public void inorder(TreeNode root, List< Integer > list) {
        // 中序遍历
        if (root == null) {
            return;
        }
        inorder(root.left, list);
        list.add(root.val);
        inorder(root.right, list);
    }
}
